package com.seed.util;

import cn.hutool.core.util.StrUtil;
import com.seed.core.action.Action;
import com.seed.core.enumeration.ActionType;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ActionsKit {
    public static Map<String, Action> initMethods(Map<String, Action> actions) {
//        for (Map.Entry<String, Action> entry : actions.entrySet()) {
//            Action action = entry.getValue();
//            ActionType type = action.getType();
//            if (type == null) continue;
//
//            List<RequestMethod> methods = switch (type) {
//                case page, detail, get, getBatch, stat, exportExcel -> List.of(RequestMethod.GET);
//                case save, saveBatch, importExcel -> List.of(RequestMethod.POST);
//                case update, updateBatch -> List.of(RequestMethod.GET, RequestMethod.PUT);
//                case set, setBatch -> {
//                    List<RequestMethod> list = new ArrayList<>();
//                    if (StrUtil.isBlank(action.getDeclareValue())) {
//                        list.add(RequestMethod.GET);
//                    }
//                    list.add(RequestMethod.PUT);
//                    yield list;
//                }
//                case remove, removeBatch -> List.of(RequestMethod.DELETE);
//            };
//            action.setMethods(methods);
//        }

        return actions;
    }
}
